<?php


namespace Frieza\Modules\RiskContent\Actions;

use Doraemon\cache\ToBan;
use Doraemon\model\AdmOperateLog;
use Doraemon\module\ContentChecking\Common\AuditCommand;
use Doraemon\module\ContentChecking\Service\CheckLog;
use Doraemon\tools\Log;
use Encore\Admin\Actions\RowAction;
use Encore\Admin\Facades\Admin;
use Illuminate\Http\Request;

class Approved extends RowAction
{
    public $name = '审核通过';
    const TOAST_ALERT = '你确定要忽略此用户吗？';

    public function handle($logId)
    {

        $command = new AuditCommand();

        $command->adminId = Admin::user()->id;
        $command->Id = $logId;

        $checkLogService = new CheckLog();
        $res = $checkLogService->approved($command);

        if ($res) {
            return $this->response()->success('审核成功')->refresh();
        } else {
            return $this->response()->error('操作失败,稍后重试!');
        }


    }

    public function retrieveModel(Request $request)
    {
        if (!$key = $request->get('_key')) {
            return false;
        }

        return $key;
    }

}